# test_win32gui.py
try:
    import win32gui

    print("win32gui模块导入成功！")

    # 测试一些基本功能
    print(f"模块路径: {win32gui.__file__}")

    # 尝试获取桌面窗口句柄
    desktop_hwnd = win32gui.GetDesktopWindow()
    print(f"桌面窗口句柄: {desktop_hwnd}")

    # 尝试获取前台窗口
    foreground_hwnd = win32gui.GetForegroundWindow()
    foreground_title = win32gui.GetWindowText(foreground_hwnd)
    print(f"前台窗口: {foreground_title}, 句柄: {foreground_hwnd}")

except ImportError as e:
    print(f"导入失败: {e}")
except AttributeError as e:
    print(f"属性错误: {e}")
except Exception as e:
    print(f"其他错误: {e}")